package other;

import java.util.Scanner;

public class intervalSum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt(),i=0;
        int[]nums=new int[len];
        while (len-- > 0)
            nums[i++] = sc.nextInt();
        while(sc.hasNext()){
            int start = sc.nextInt();
            int end = sc.nextInt();
            int sum=0;
            for(int j=start;j<=end;j++)
                sum+=nums[j];
            System.out.println(sum);
        }
    }
}
